package com.atguigu.common.exception;

import com.atguigu.common.result.ResponseEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class BusinessException extends  RuntimeException {
     //状态码
     private Integer code;
     //错误消息
     private String message;

    public BusinessException(String message, Integer code) {
        this.message=message;
        this.code = code;

    }



    public BusinessException(String message) {
        this.message = message;
    }
    // 错误信息，状态码，原始异常信息
    public BusinessException(String message,Integer code,Throwable cause){
      super(cause);
      this.message=message;
      this.code = code;
    }

    public  BusinessException(ResponseEnum responseEnum){
        this.message= responseEnum.getMessage();
        this.code = responseEnum.getCode();
    }

    public  BusinessException(ResponseEnum resultcodeEnum,Throwable cause){
        super(cause);
        this.message= resultcodeEnum.getMessage();
        this.code= resultcodeEnum.getCode();
    }


}
